package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) throws Exception {
        //根据用户名修改用户昵称
        Connection connection = DBUtil.getConnection();
        Statement statement = connection.createStatement();
        String sql= "UPDATE userinfo\n" +
                "SET nickname='晶晶'\n" +
                "WHERE username='王克晶'";
        int num = statement.executeUpdate(sql);
        if(num>0){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
        connection.close();
    }
}
